<template>
  <!-- 对话框 -->
  <div>
    <el-dialog :title="dialogTitle" :visible="dialogVisible" width="50%" :before-close="handleClose">
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-row>
          <el-col :span="12">
            <el-form-item prop="type2" label="一级菜单">
              <el-input v-model="form.type2" size="mini" placeholder="请输入一级菜单" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="type3" label="二级菜单">
              <el-input v-model="form.type3" size="mini" placeholder="请输入二级菜单" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item prop="code" label="输入">
              <el-input v-model="form.code" size="mini" placeholder="请输入'输入'" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="code2" label="输出">
              <el-input v-model="form.code2" size="mini" placeholder="请输入输出" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item prop="enName" label="英文名">
              <el-input v-model="form.enName" size="mini" placeholder="请输入英文名" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="cnName" label="中文名">
              <el-input v-model="form.cnName" size="mini" placeholder="请输入中文名" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item prop="orderIndex" label="排序">
              <el-input v-model="form.orderIndex" size="mini" placeholder="请输入排序" />
            </el-form-item>
        <el-row>
          <el-col :span="12">
            <el-form-item prop="img1" label="图标1">
              <el-input v-model="form.img1" size="mini" placeholder="请输入图标1" />
            </el-form-item>
          </el-col>
          <el-col :span="2">
            <img v-if="form.img1" style="margin-top: 5px;" :src= "imgBaseUrl + form.img1" width="30px"/>
          </el-col>
          <el-col :span="3">
            <el-button size="mini" style="margin-top: 6px;" @click="showImg('img1')">选择</el-button>
          </el-col>
         
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item prop="img2" label="图标2">
              <el-input v-model="form.img2" size="mini" placeholder="请输入图标2" />
            </el-form-item>
          </el-col>
          <el-col :span="2">
            <img v-if="form.img2" style="margin-top: 5px;" :src= "imgBaseUrl + form.img2" width="30px"/>
          </el-col>
          <el-col :span="3">
            <el-button size="mini" style="margin-top: 6px;" @click="showImg('img2')">选择</el-button>
          </el-col>
          
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item prop="img3" label="图标3">
              <el-input v-model="form.img3" size="mini" placeholder="请输入图标3" />
            </el-form-item>
          </el-col>
          <el-col :span="2">
            <img v-if="form.img3" style="margin-top: 5px;" :src= "imgBaseUrl + form.img3" width="30px"/>
          </el-col>
          <el-col :span="3">
            <el-button size="mini" style="margin-top: 6px;" @click="showImg('img3')">选择</el-button>
          </el-col>
          
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item prop="img4" label="图标4">
              <el-input v-model="form.img4" size="mini" placeholder="请输入图标4" />
            </el-form-item>
          </el-col>
          <el-col :span="2">
            <img v-if="form.img4" style="margin-top: 5px;" :src= "imgBaseUrl + form.img4" width="30px"/>
          </el-col>
          <el-col :span="3">
            <el-button size="mini" style="margin-top: 6px;" @click="showImg('img4')">选择</el-button>
          </el-col>
         
        </el-row>
        <el-form-item>
          <el-row type="flex" justify="end" style="margin-top: 10px;">
            <el-button size="mini" @click="handleClose">取 消</el-button>
            <el-button size="mini" type="primary" @click="btnOK">确 定</el-button>
          </el-row>
        </el-form-item>
      </el-form>
      <imgSearch ref="imgSearch" 
        dialogTitle="图标" 
        :dialog-visible.sync="imgVisible" 
        :data="this"
        />
    </el-dialog>
    
  </div>

</template>

<script>
import baseData from '@/baseData'
import imgSearch from '../../img/imgSearch.vue'
export default {
  name: 'TypeAdd',
  components: {
      imgSearch,
    },
  props: {
    dialogVisible: {
      default: false,
      type: Boolean
    },
    dialogTitle:'',
    form:{},
    options:[],
    data:null,
  },
  data() {
    return {
      imgBaseUrl:baseData.basePathUser+'/tbFile/fileById?id=',
      rules:[],
      img:'',
      imgVisible:false,
    }
  },
  watch: {
    
  },
  mounted() {

  },

  methods: {
    // 取消
    handleClose() {
      this.$emit('update:dialogVisible', false)
    },

    // 确定
    async btnOK() {
      this.data.fn.submit();
    },
   
    Close() {
      this.showVisible = false
      this.handleClose()
    },
    showImg(img){
      this.img = img
      this.imgVisible = true
    },
    selectImg(id){
      this.form[this.img] = id
      this.imgVisible = false
    }
  }
}
</script>

<style lang="scss" scoped></style>
